w = cogl_texture_get_width (self->background_texture);
h = cogl_texture_get_height (self->background_texture);
- /* scale the background into the allocated bounds */
- if (w > result->x2 || h > result->y2)
+ /* scale the background into the allocated bounds, when not being absolutely positioned */
+ if ((w > result->x2 || h > result->y2) && !self->background_position_set)
{
gint new_h, new_w, offset;
gint box_w, box_h;
}
else
{
- /* center the background on the widget */
- result->x1 = (int)(((allocation->x2 - allocation->x1) / 2) - (w / 2));
- result->y1 = (int)(((allocation->y2 - allocation->y1) / 2) - (h / 2));
+ /* honor the specified position if any */
+ if (self->background_position_set)
+ {
+ result->x1 = self->background_position_x;
+ result->y1 = self->background_position_y;
+ }
+ else
+ {
+ /* center the background on the widget */
+ result->x1 = (int)(((allocation->x2 - allocation->x1) / 2) - (w / 2));
+ result->y1 = (int)(((allocation->y2 - allocation->y1) / 2) - (h / 2));
+ }
result->x2 = result->x1 + w;
result->y2 = result->y1 + h;
}
StGradientType background_gradient_type;
ClutterColor background_gradient_end;
+ int background_position_x;
+ int background_position_y;
+ gboolean background_position_set : 1;
+
ClutterColor foreground_color;
ClutterColor border_color[4];
ClutterColor outline_color;
return VALUE_NOT_FOUND;
case NUM_GENERIC:
- g_warning ("length values must specify a unit");
- return VALUE_NOT_FOUND;
+ {
+ if (num->val != 0)
+ {
+ g_warning ("length values must specify a unit");
+ return VALUE_NOT_FOUND;
+ }
+ else
+ {
+ type = ABSOLUTE;
+ multiplier = 0;
+ }
+ break;
+ }
case NUM_PERCENTAGE:
g_warning ("percentage lengths not currently supported");
node->background_computed = TRUE;
node->background_color = TRANSPARENT_COLOR;
node->background_gradient_type = ST_GRADIENT_NONE;
+ node->background_position_set = FALSE;
ensure_properties (node);
node->background_color = TRANSPARENT_COLOR;
g_free (node->background_image);
node->background_image = NULL;
+ node->background_position_set = FALSE;
for (term = decl->value; term; term = term->next)
{
}
}
}
+ else if (strcmp (property_name, "-position") == 0)
+ {
+ GetFromTermResult result = get_length_from_term_int (node, decl->value, FALSE, &node->background_position_x);
+ if (result == VALUE_NOT_FOUND)
+ {
+ node->background_position_set = FALSE;
+ continue;
+ }
+ else
+ node->background_position_set = TRUE;
+
+ result = get_length_from_term_int (node, decl->value->next, FALSE, &node->background_position_y);
+
+ if (result == VALUE_NOT_FOUND)
+ {
+ node->background_position_set = FALSE;
+ continue;
+ }
+ else
+ node->background_position_set = TRUE;
+ }
else if (strcmp (property_name, "-color") == 0)
{
GetFromTermResult result;